package ServletService;

import javax.naming.InitialContext;
import javax.naming.NamingException;

import service.ServiceException;
import service.local.CandidateService;
import service.local.CommentService;
import service.local.DepartmentService;
import service.local.InterviewService;
import service.local.PositionService;
import service.local.RoleService;
import service.local.UserService;

public class Service {
	
	public static UserService getUserService(){
		InitialContext ic;
		UserService us = null;
		try{
			ic = new InitialContext();
			us = (UserService) ic.lookup("java:global/jthr-server/jthr-backend-0.0.1-SNAPSHOT/UserService!service.local.UserService");
			
	    } catch (NamingException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
		}
		return us;
	}
	
	public static PositionService getPositionService(){
		InitialContext ic;
		PositionService ps = null;
		try{
			ic = new InitialContext();
			ps = (PositionService) ic.lookup("java:global/jthr-server/jthr-backend-0.0.1-SNAPSHOT/PositionService!service.local.PositionService");
			
	    } catch (NamingException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
		}
		return ps;
	}
	
	public static CandidateService getCandidateService(){
		InitialContext ic;
		CandidateService cs = null;
		try{
			ic = new InitialContext();
			cs = (CandidateService) ic.lookup("java:global/jthr-server/jthr-backend-0.0.1-SNAPSHOT/CandidateService!service.local.CandidateService");
			
	    } catch (NamingException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
		}
		return cs;
	}
	
	public static CommentService getCommentService(){
		InitialContext ic;
		CommentService cs = null;
		try{
			ic = new InitialContext();
			cs = (CommentService) ic.lookup("java:global/jthr-server/jthr-backend-0.0.1-SNAPSHOT/CommentService");
			
	    } catch (NamingException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
		}
		return cs;
	}
	
	public static InterviewService getInterviewService(){
		InitialContext ic;
		InterviewService is = null;
		try{
			ic = new InitialContext();
			is = (InterviewService) ic.lookup("java:global/jthr-server/jthr-backend-0.0.1-SNAPSHOT/InterviewService");
			
	    } catch (NamingException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
		}
		return is;
	}
	
	public static DepartmentService getDepartmentService(){
		InitialContext ic;
		DepartmentService ds = null;
		try{
			ic = new InitialContext();
			ds = (DepartmentService) ic.lookup("java:global/jthr-server/jthr-backend-0.0.1-SNAPSHOT/DepartmentService");
			
	    } catch (NamingException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
		}
		return ds;
	}
	
	public static RoleService getRoleService(){
		InitialContext ic;
		RoleService rs = null;
		try{
			ic = new InitialContext();
			rs = (RoleService) ic.lookup("java:global/jthr-server/jthr-backend-0.0.1-SNAPSHOT/RoleService!service.local.RoleService");
			
	    } catch (NamingException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
		}
		return rs;
	}
}
